﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Tools
{
    public static class PreUrl
    {
        public static string AddHttp(string Url)
        {
            if (!String.IsNullOrEmpty(Url))
                if (Url.IndexOf("http://") != 0)
                    if (Url[0] == '/')
                        Url = "http://" + HttpContext.Current.Request.Url.Authority + Url;
                    else
                        Url = "http://" + HttpContext.Current.Request.Url.Authority + "/" + Url;
            return Url;
        }

        public static string AddPermissions(string Url, string Permissions)
        {
            if (!String.IsNullOrEmpty(Url))
                if (Url.IndexOf("?") > 0)
                {
                    if (Url[Url.Length - 1] == '?')
                        Url += "Permissions=" + HttpContext.Current.Server.UrlEncode(Permissions);
                    else
                        Url += "&Permissions=" + HttpContext.Current.Server.UrlEncode(Permissions);
                }
                else
                {
                    Url += "?Permissions=" + HttpContext.Current.Server.UrlEncode(Permissions);
                }
            return Url;
        }
    }
}
